package org.example.weather.bigscreen.core.service;

import org.example.weather.bigscreen.core.api.dto.AreaDTO;
import org.example.weather.bigscreen.core.entity.TblArea;
import org.example.weather.bigscreen.core.repository.TblAreaMapper;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AreaService {

    private TblAreaMapper tblAreaMapper;
    private ModelMapper modelMapper;

    public AreaService(final TblAreaMapper tblAreaMapper, final ModelMapper modelMapper) {
        this.tblAreaMapper = tblAreaMapper;
        this.modelMapper = modelMapper;
    }

    public AreaDTO selectById(String areaId) {
        TblArea tblArea = tblAreaMapper.selectById(areaId);
        return  modelMapper.map(tblArea, AreaDTO.class);
    }
    public List<AreaDTO> selectByIds(List<String> areaIds) {

        return tblAreaMapper.selectByIds(areaIds);
    }
    public AreaDTO selectParent(String areaId) {

        return tblAreaMapper.selectParent(areaId);
    }
    public List<AreaDTO> selectAncestors(String areaId) {

        return tblAreaMapper.selectAncestors(areaId);
    }

    public  AreaDTO selectAncestor(String areaId, Integer level) {

         return tblAreaMapper.selectAncestor(areaId,level);
    }

    public List<AreaDTO> selectByParentId(String parentId) {

        return tblAreaMapper.selectByParentId(parentId);
    }
    public List<AreaDTO> selectDescendants(String parentId) {

        return tblAreaMapper.selectDescendants(parentId);
    }

    public List<AreaDTO> selectByLevel(Integer level) {

        return tblAreaMapper.selectByLevel(level);
    }
    public List<AreaDTO> selectAll() {

        return tblAreaMapper.selectAll();
    }

}


